package mop.exception;

/**
 * Exception class for incorrect Descriptions
 * 
 * @invar none this is a exception
 * 
 * @author	 MOP Team 7
 */
public class IllegalDescriptionException extends Throwable 
{

	/**
	 * Initializes an IllegalDescriptionException with the passed description
	 * 
	 * @param description
	 *  the description thats incorrect
	 *  
	 * @effect sets the description
	 */
	public IllegalDescriptionException(String description)
	{
		this.setDescription(description);
	}
	
	/**
	 * return a error message that can be used by the gui
	 * 
	 * @return an error message describing the incorrect name
	 */
	public String toString()
	{
		
		StringBuffer sb = new StringBuffer();
		sb.append("The following description is not a valid one ! ");
		
		if(this.description == null)
			sb.append("NULL");
		else if (this.description.trim().equals(""))
			sb.append("/emptyString");
		else
			sb.append(this.description);
		
		return sb.toString();
		
	}
	
	 /**
	  * set the description
	  * 
	  * @param description
	  *  the description that's causing trouble
	  *  
	  * @post the description is set to the passed one
	  * 
	  */
	 private void setDescription(String description) 
	 {

		 this.description = description;
	 }
	
	/**
	 * weird java demand
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * the description thats causing the problem
	 */
	private String description;
	
}